package cn.jiangjiesheng.bootstrap.filestore.impl;


import cn.jiangjiesheng.bootstrap.filestore.dto.ResultMap;

import java.io.InputStream;
import java.util.Date;

/**
 * 定义文件操作的方法
 * <p>
 * Created by dev@jiangjiesheng.cn on 2021/7/14  <br/>
 */
public interface IFileStoreOperator {

    /**
     * 返回uploadId
     *
     * @param bucket
     * @param objectId
     * @param filepath
     * @return
     */
    String putBigObject(String bucket, String objectId, String filepath);

    String putBigObject(String objectId, String filepath);

    /**
     * 上传文件
     *
     * @param bucket
     * @param objectId
     * @param fileData
     */
    void putObject(String bucket, String objectId, InputStream fileData);

    void putObject(String objectId, InputStream fileData);

    InputStream getObject(String bucket, String objectId);

    void publicRead(String bucket, String objectId, boolean enabled);

    default void publicRead(String objectId, boolean enabled){

    }

    void copyObject(String bucket, String objectId,
                    String targetBucket, String targetObjectId);

    Boolean doesBucketExists(String bucket);

    void createBucket(String bucket);

    void deleteObject(String bucket, String objectId);

    ResultMap deleteMultipleObjects(String bucket, String... objectIds);

    ResultMap doesObjectsExists(String bucket, String... objectIds);

    Boolean doesObjectExists(String bucket, String objectId);

    /**
     * HeadObject接口用于获取某个文件（Object）的元信息。使用此接口不会返回文件内容。
     */
    ResultMap getObjectMeta(String bucket, String objectId);

    /**
     * 获取自签名后的URL,默认3个小时
     *
     * @param objectIds
     * @return
     */
    ResultMap generatePreSignedURL(String bucket, String... objectIds);

    ResultMap generatePreSignedURL(String bucket, Date expiration, String... objectIds);


    InputStream getObject(String objectId);

    void deleteObject(String objectId);

    ResultMap deleteMultipleObjects(String... objectIds);

    ResultMap doesObjectsExists(String... objectIds);

    Boolean doesObjectExists(String objectId);

    /**
     * HeadObject接口用于获取某个文件（Object）的元信息。使用此接口不会返回文件内容。
     */
    ResultMap getObjectMeta(String objectId);

    /**
     * 获取自签名后的URL,默认3个小时
     *
     * @param objectId
     * @return
     */
    ResultMap generatePreSignedURL(String objectId);

    ResultMap generatePreSignedURL(String... objectIds);

    ResultMap generatePreSignedURL(Date expiration, String... objectIds);

    void close();
}
